Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-implement-and-rewrite#1240
Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-implement-and-rewrite#1240marthak1 wants to merge 9 commits intoCodeYourFuture:mainfrom
Conversation
There was a problem hiding this comment.
I think you should check the definition of a proper fraction again and see if your test case for negative numbers is correct expecially -3/8. I will advise you to use Match.abs()
There was a problem hiding this comment.
Thanks for the feedback! My implementation checks whether the value of the fraction is between 0 and 1, which is the standard mathematical definition of a proper fraction. Based on that definition:
-3/8 → -0.375 → not proper
-8/-3 → 2.66… → not proper
-3/-8 → 0.375 → proper
Using Math.abs() would treat negative fractions like -3/8 as proper, even though their value is negative. That’s why I didn’t use Math.abs(), and why my tests reflect the “between 0 and 1” definition. Happy to adjust if a different definition is expected.
There was a problem hiding this comment.
The first rule of a proper fraction is that the numerator is less than the denominator. Your solution will fail on most negative numbers. Reason why a proper fraction is when the absolute value of the numerator is less than the absolute value of the denominator. A proper fraction is always less than 1
Based on your code, let's consider the following examples
you are returning properFraction > 0 && properFraction < 1
-1/2 will return false because the division is -0.5, and it is not greater than 0. But this is wrong as the result is less than 1 and the first rule of numerator < denominator stands.
Same thing with -3/8.
You can check this for further info https://www.splashlearn.com/math-vocabulary/proper-fraction
Math.abs() helps you work with negative numbers.
You can do more research on it.
There was a problem hiding this comment.
Thanks for explaining! I understand now that you're using the definition based on absolute values. I’ll update my code and tests to use Math.abs() so it matches that approach.
| test(`Should throw an error`, () => { | ||
| expect(() => { | ||
| getCardValue("♠9"); | ||
| }).toThrow(); |
There was a problem hiding this comment.
This is good. To take it further, add a test to see if the returned error message is what you are expecting.
There was a problem hiding this comment.
Thank you for the feedback . Would add further test to see what error messages they return.
|
Your recent commits added a solution for 2-practice-tdd. The Readme file for Sprint-3 says 1 pull request per directory, so 2-practice-tdd is supposed to have its own pull request. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
17cc045 to
06520c4
Compare
|
@marthak1 noticed a lot of activities on the pull request. tag me on the pull request when it is ready to be reviewed again |
Fix test case for negative numerator in isProperFraction.
|
@Edu-Vin added the changes to the proper fraction function |
Learners, PR Template
Self checklist
Changelist